import{LOGIN_ERROR,LOGIN_SUCCESS} from "../action-types"

const initialState = {
    user: null,
    error: null,
}

function auth(state = initialState, action) {
    switch (action.type) {
        case LOGIN_SUCCESS:
            return {
                ...state,
                user: action.payload,
                error: null,
            }
        case LOGIN_ERROR:
            return {
                ...state,
                error: action.payload,
            }
        default:
            return state
    }
}

export default auth